package com.qq986945193.davidbookstore.cart.domain;
/**
 * 
 */
import java.math.BigDecimal;

import org.junit.Test;

import com.qq986945193.davidbookstore.book.domain.Book;

/**
 * 购物车条目类
 */
public class CartItem {
	private Book book;// 商量
	private int count;// 数量

	/**
	 * 小计方法，处理了二进制运算的误差问题
	 * 
	 * @return
	 */
	public double getSubtotal() {// 小计方法，但它没有对应的成员
		BigDecimal decimalPrice = new BigDecimal(book.getPrice() + "");
		BigDecimal decimalCount = new BigDecimal(count + "");
		return decimalPrice.multiply(decimalCount).doubleValue();
	}

	public CartItem(Book book, int count) {
		super();
		this.book = book;
		this.count = count;
	}

	public CartItem() {
		super();
	}

	public Book getBook() {
		return book;
	}

	public void setBook(Book book) {
		this.book = book;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

}
